//
// Created by 123 on 2025/1/3.
//
#include "iostream"
#include "fstream"
#include "string"
using namespace std;

class Person{
public:
    char m_name[64];
    int m_age;
};

void test(){
    ofstream ofs("person.txt",ios::out | ios::binary);
    Person p = {"zhangsan",18};
    ofs.write((const char*)&p, sizeof(p));
    ofs.close();

    ifstream ifs("person.txt",ios::in | ios::binary);
    if(!ifs.is_open()){
        cout << "open file fail" <<endl;
    }
    Person p2;
    ifs.read((char*)&p2,sizeof(p2));
    cout << "name==" << p2.m_name << " age=" << p2.m_age << endl;

}

int main095(){
    test();

    return 0;
}

